use Yokoyama_Kobayashi_JJPS_replication.dta,clear
set more off

********************
*** Preparations ***
********************

* Party support(0: incumbent parties; 1: opposition parties)
gen ptysup =  .
replace ptysup = 0 if ((therldp > therdpj & therldp > therjcp) & therldp !=. & therkoumei !=. & therdpj !=. & therjcp !=.) | ///
((therkoumei > therdpj & therkoumei > therjcp) & therldp !=. & therkoumei !=. & therdpj !=. & therjcp !=.) 

replace ptysup = 1 if ((therdpj > therldp & therdpj > therkoumei) & therldp !=. & therkoumei !=. & therdpj !=. & therjcp !=.) | ///
((therjcp > therldp & therjcp > therkoumei) & therldp !=. & therkoumei !=. & therdpj !=. & therjcp !=.)

label define ptysup 0 "Incumbent party supporters" 1 "Opposition party supporters"
label values ptysup ptysup
label variable ptysup "Party support"


***************
*** Table 2 ***
***************

/*Treatment effect of party and leader cues on 
policy approval rate */

*Model 1 in Table 2 (Treatment effect without the covariates)
reg apvrate i.ptysup##i.expcond

*Model 2 in Table 2 (Treatment effect with the covariates)
reg apvrate i.ptysup##i.expcond sex age cabapp asahi

*Model 3 in Table 2 (Average treatment effects without the covariates)
reg apvrate i.expcond if ptysup == 0 | ptysup == 1

*Model 4 in Table 2 (Average treatment effects with the covariates)
reg apvrate i.expcond sex age cabapp asahi if ptysup == 0 | ptysup == 1


*******************************
*** Linear combination test ***
*******************************

/* H1: Comparing the mean differences between the control condition and 
the prime minister cue condition among incumbent party supporters */
reg apvrate i.ptysup##i.expcond sex age cabapp asahi
lincom ((_cons + sex + age + cabapp + asahi + 0.ptysup + _b[1.expcond] + [0.ptysup#1.expcond])) - ///
 (_cons + sex + age + cabapp + asahi + 0.ptysup + _b[8.expcond] + [0.ptysup#8.expcond])

/* H2: Comparing the mean differences between the control condition and 
the prime minister cue condition  among opposition party supporters */
reg apvrate i.ptysup##i.expcond sex age cabapp asahi
lincom ((_cons + sex + age + cabapp + asahi + 1.ptysup + _b[1.expcond] + [1.ptysup#1.expcond])) - ///
 (_cons + sex + age + cabapp + asahi + 1.ptysup + _b[8.expcond] + [1.ptysup#8.expcond])

/* H3: Comparing the mean differences between the LDP condition and 
the prime minister cue condition among incumbent party supporters */
reg apvrate i.ptysup##i.expcond sex age cabapp asahi
lincom ((_cons + sex + age + cabapp + asahi + 0.ptysup + _b[2.expcond] + [0.ptysup#2.expcond]) - ///
 (_cons + sex + age + cabapp + asahi + 0.ptysup + _b[8.expcond] + [0.ptysup#8.expcond]))

/* H4: Comparing the mean differences between the LDP condition and 
the prime minister cue condition among opposition party supporters */
reg apvrate i.ptysup##i.expcond sex age cabapp asahi
lincom ((_cons + sex + age + cabapp + asahi + 1.ptysup + _b[2.expcond] + [1.ptysup#2.expcond]) - ///
 (_cons + sex + age + cabapp + asahi + 1.ptysup + _b[8.expcond] + [1.ptysup#8.expcond]))


****************
*** Figire 1 ***
****************

/* Treatment effects of LDP and prime minister cues on policy approval rate) */
reg apvrate i.ptysup##i.expcond sex age cabapp asahi
eststo Control: margins, at (expcond = 1 ptysup = (0 1)) post // Control

reg apvrate i.ptysup##i.expcond sex age cabapp asahi
eststo LDP:margins, at (expcond = 2 ptysup = (0 1)) post // LDP

reg apvrate i.ptysup##i.expcond sex age cabapp asahi
eststo PM:margins, at (expcond = 8 ptysup = (0 1)) post // PM

coefplot (Control, label(Control) lcolor(Black) fcolor(white)) ///
(LDP, label(LDP) lcolor(Black) fcolor(gs5)) /// 
(PM, label(Prime Minister) lcolor(Black) fcolor(gs10)), ///
ytitle("Policy approval rate (%)", size(small)) ///
ylabel(0(10)100, tposition(outside) glcolor(gs15)) ///
xlabel(, labsize(small)) ///
rename (1._at = "Incumbent party supporters" 2._at = "Opposition party supporters") ///
vertical recast(bar) barwidth(0.25) fcolor(*.5) ///
ciopts(lcolor(black) lwidth(thin) recast(rcap)) citop ///
ytick(,glcolor(gs15)) ///
graphregion(fcolor(white)) ///
graphregion(color(white))


****************
*** Figire 2 ***
****************

/*Treatment effects of multiple-party cues on policy approval rate */
reg apvrate i.expcond ///
sex age cabapp asahi if ptysup == 0 | ptysup == 1
eststo Control: margins, at (expcond = 1) post // Control

reg apvrate i.expcond ///
sex age cabapp asahi if ptysup == 0 | ptysup == 1
eststo LDP_DPJ: margins, at (expcond = 5) post // LDP & DPJ

reg apvrate i.expcond ///
sex age cabapp asahi if ptysup == 0 | ptysup == 1
eststo LDP_JCP: margins, at (expcond = 6) post // LDP & JCP

reg apvrate i.expcond ///
sex age cabapp asahi if ptysup == 0 | ptysup == 1
eststo LDP_DPJ_JCP: margins, at (expcond = 7) post // LDP, DPJ, & JCP

coefplot (Control, label(Control) lcolor(black) fcolor(white)) ///
(LDP_DPJ, label(LDP & DPJ) lcolor(black) fcolor(dimgray)) ///
(LDP_JCP, label(LDP & JCP) lcolor(black) fcolor(gs10)) ///
(LDP_DPJ_JCP, label(LDP, DPJ, & JCP) lcolor(black) fcolor(gs5)), ///
ytitle("Policy approval rate (%)", size(small)) ///
ylabel(0(10)100, tposition(outside) glcolor(gs15)) ///
xlabel(, nolabels noticks) ///
vertical recast(bar) barwidth(0.2) fcolor(*.5) ///
ciopts(lcolor(black) lwidth(thin) recast(rcap)) citop ///
ytick(,glcolor(gs15)) ///
graphregion(fcolor(white)) ///
graphregion(color(white))


****************
*** Table A1 ***
****************

/* Logistic regression predicting sample attrition */
use Yokoyama_Kobayashi_JJPS_replication.dta,clear
set more off

logit attrition ib0.sex##i.expcond c.age##i.expcond c.edu##i.expcond


****************
*** Table A2 ***
****************

/*Covariate balance among the entire sample of the pretreatment survey (N = 1,800) */
use Yokoyama_Kobayashi_JJPS_replication.dta,clear
set more off

tab sex expcond, chi col
for var age edu: oneway X expcond,t


****************
*** Table A3 ***
****************

/*Covariate balance among the subsample of valid participants with completed responses (N = 780) */
drop if ptysup == .

tab sex expcond, chi col
for var age - nikkei: oneway X expcond, t

****************
*** Table A4 ***
****************
use Yokoyama_Kobayashi_JJPS_replication.dta,clear

drop if attrition == 1

*Set the data for use with mi
mi set mlong

*Register imputation variables
mi register imputed therldp therkoumei therdpj therjcp
mi register regular sex age edu polint cabapp ///
nhk nnn ann jnn txn fnn yomiuri asahi mainichi sankei nikkei 											

*Use mi impute to fill in missing values in the feeling thermometer scores for parties
mi impute pmm therldp  = sex age edu polint cabapp ///
nhk nnn ann jnn txn fnn yomiuri asahi mainichi sankei nikkei, knn(1) add(20) rseed(1222) replace

mi impute pmm therkoumei = sex age edu polint cabapp ///
nhk nnn ann jnn txn fnn yomiuri asahi mainichi sankei nikkei, knn(1) rseed(1222) replace

mi impute pmm therdpj  = sex age edu polint cabapp ///
nhk nnn ann jnn txn fnn yomiuri asahi mainichi sankei nikkei, knn(1) rseed(1222) replace

mi impute pmm therjcp  = sex age edu polint cabapp ///
nhk nnn ann jnn txn fnn yomiuri asahi mainichi sankei nikkei, knn(1) rseed(1222) replace

mi xeq 0 1 20: summarize therldp therkoumei therdpj therjcp

* Party support(0: incumbent parties; 1: opposition parties)
mi passive: generate mi_ptysup = .
mi xeq: tab mi_ptysup

mi passive: replace mi_ptysup = 0 if ((therldp > therdpj & therldp > therjcp) & therldp !=. & therkoumei !=. & therdpj !=. & therjcp !=.) | ///
((therkoumei > therdpj & therkoumei > therjcp) & therldp !=. & therkoumei !=. & therdpj !=. & therjcp !=.) 

mi passive: replace mi_ptysup = 1 if ((therdpj > therldp & therdpj > therkoumei) & therldp !=. & therkoumei !=. & therdpj !=. & therjcp !=.) | ///
((therjcp > therldp & therjcp > therkoumei) & therldp !=. & therkoumei !=. & therdpj !=. & therjcp !=.)

label define mi_ptysup 0 "Incumbent party supporters" 1 "Opposition party supporters"
label values mi_ptysup mi_ptysup
label variable mi_ptysup "Party support"

/*Treatment effect of party and leader cues on 
policy approval rate using multiple-imputation analysis */

*Model 1 in Table A4 (Treatment effect without the covariates)
mi estimate, esampvaryok nowarning: reg apvrate i.mi_ptysup##i.expcond

*Model 2 in Table A4 (Treatment effect with the covariates)
mi estimate, esampvaryok nowarning: reg apvrate i.mi_ptysup##i.expcond sex age cabapp asahi

*Model 3 in Table A4 (Average treatment effects without the covariates)
mi estimate, esampvaryok nowarning: reg apvrate i.expcond ///
if mi_ptysup == 0 | mi_ptysup == 1

*Model 4 in Table A4 (Average treatment effects with the covariates)
mi estimate, esampvaryok nowarning: reg apvrate i.expcond sex age cabapp asahi ///
if mi_ptysup == 0 | mi_ptysup == 1

